import os
import sys

if(len(sys.argv) > 1):
    fileToProcess =  sys.argv[1]

    fileToSave = open(fileToProcess.split(".")[0]+".cleaned","w")
    fileToSave_dirty = open(fileToProcess.split(".")[0]+".dirty","w")
    
    fileToRead = open(fileToProcess)

    for eachLine in fileToRead.readlines():
        eachLine = eachLine.strip()

        rank = eachLine.split("\t")[3]
        if(rank =='-1' and len(eachLine.split("\t")) < 5 ):
           fileToSave_dirty.write(eachLine+"\n")
        else:
            fileToSave.write(eachLine+"\n")

    fileToSave.close()
    fileToSave_dirty.close()
    fileToRead.close()
            
